//
//  pureTextViewController.m
//  YiXiu
//
//  Created by ZHY on 16/6/27.
//  Copyright © 2016年 zzz. All rights reserved.
//

#import "pureTextViewController.h"
#import "AutoSizeTableViewCell.h"
#import "UserViewController.h"
#import "TextUserController.h"
#import "UserViewController.h"

@interface pureTextViewController ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic, strong) NSArray * cellModels;

@property (nonatomic, strong) UITableView  *tableView;



@end

@implementation pureTextViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor blueColor];
    
    
    
    NSMutableArray * Marr = [NSMutableArray array];
    for (int i = 0; i < 30; i++) {
        AutoSizeModel * model = [[AutoSizeModel alloc] init];
//        model.contentText = [AutoSizeModel ]
        model.name = @"一羞大师";
        model.isHot = i > 6;
        model.contentText = [model.contentText substringFromIndex:i];
        model.contentTextFont = [UIFont systemFontOfSize:18];
        //        model.contentText = nil;
        
//        model.contentImages = @[@"asdfasfd"];
        model.contentImages = nil;
        
        model.Zang = [NSString stringWithFormat:@"%d",i+300];
        model.Pinlun = [NSString stringWithFormat:@"%d",i+3000];
        model.Fenxian = [NSString stringWithFormat:@"%d",i+200];
        //        [model.Zang setImage:[UIImage imageNamed:@"icon_n1"] forState:UIControlStateNormal];
        
        [Marr addObject:model];
    }
    
    self.cellModels = Marr;
    
    [self.view addSubview:self.tableView];
    
}

-(UITableView *)tableView{
    
    if (!_tableView) {
        _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, WidthOfView([UIScreen mainScreen]), HeightOfView([UIScreen mainScreen]) - 108) style:UITableViewStylePlain];
        _tableView.delegate = self;
        _tableView.dataSource = self;
        
    }
    return _tableView;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return self.cellModels.count;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    AutoSizeTableViewCell * cells = [[AutoSizeTableViewCell alloc] initWithTableView:tableView];
    
    cells.model = self.cellModels[indexPath.row];
    
    [cells setIconBlock:^{
        NSLog(@"%s",__func__);
        
        UserViewController * userVC = [[UserViewController alloc]init];
        
        [self.superVC.navigationController pushViewController:userVC animated:YES];
        
    }];
    
    
    [cells setTextBlock:^{
        TextUserController * textUser = [[TextUserController alloc]init];
        
        [self.superVC.navigationController pushViewController:textUser animated:YES];
    }];
    
    
    return cells;
    
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    AutoSizeModel * model = self.cellModels[indexPath.row];
    
    return model.totalHeight;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    UITableViewCell * cell = [tableView cellForRowAtIndexPath:indexPath];
    
    cell.selected = NO;
    
}
@end
